import urllib.request
import ssl
from bs4 import BeautifulSoup

# 忽略 SSL 证书验证
ssl._create_default_https_context = ssl._create_unverified_context

url = "https://www.csdn.net/"

# 请求网页
html = urllib.request.urlopen(url)
html = html.read()
html = html.decode()

# 解析网页
soup = BeautifulSoup(html, "html.parser")

# 假设链接在 <span class="blog-text"> 的父 <a> 标签的 href 属性中
lis = soup.select("span[class='blog-text']")
for li in lis:
    # 获取父 <a> 标签
    parent_a = li.find_parent('a')
    if parent_a:
        # 获取链接
        link = parent_a.get('href')
        print(f"标题：{li.text} 链接：{link}")